<template>
    <!--components/popup/index.wxml-->
    <uPopupNew v-model="isShow" :closeIconColor="'#ffffff'" :borderRadius="20" mode="center">
		<view class="resultContainer">
			<view class="wrapper">
				<view class="title">
					恭喜你获得一个红包
				</view>		
			</view>
			<view class="btn" @click="onGetRedPacket">
				立即领取红包
			</view>
		</view>
    </uPopupNew>
</template>

<script>
	const routeList = {
	    //==首页
		'pages/shop/tabBar/index': 					'home',
		'pages/client/tabBar/index':				'home',
		
		'pages/client/pointsMall/task':				'task',
	    
	    //==活动
	    'pages/shop/activity/activityLottery':      'activity',
	    'pages/shop/activity/activityLike':         'activity',
	    'pages/shop/activity/activityCoupon':       'activity',
	    'pages/shop/activity/activityGroupBuy':     'activity',
	    'pages/shop/activity/activitySignUp':       'activity',
		'pages/shop/activity/activityHaggle':     'activity',
	    
	    
	    'pages/client/activity/activityLottery':    'activity',
	    'pages/client/activity/activityLike':       'activity',
	    'pages/client/activity/activityCoupon':     'activity',
	    'pages/client/activity/activityGroupBuy':   'activity',
	    'pages/client/activity/activitySignUp':     'activity',
	    'pages/client/activity/activityHaggle':     'activity',
	     
	    
	    //==文章
		'pages/shop/article/index':					'article',
		'pages/shop/article/articleDetail': 		'article',
		'pages/client/article/articleDetail':       'article',
	    
	    //==VR
	    'pages/shop/web/webShare':                  'panorama',
	    'pages/client/web/webShare':                'panorama',
	    'pages/shop/web/index':                     'panorama', 
	    'pages/client/web/index':                   'panorama', 
	    'pages/trtcRoom/videochat/index':            'panorama',
	                    
	    //==名片                 
	    'pages/shop/myCard/index':                  'card',
	    'pages/client/card/card':                   'card',
		
	
	    //==项目
	    'pages/shop/material/project/traffic':			    'periphery',
	    'pages/shop/material/project/building':			    'product',
	    'pages/shop/material/project/unitTypeDetail':	    'house_type', 
	    'pages/shop/material/project/buildingAlbumDetail':  'album',
	    'pages/shop/material/project/buildingVideoDetail':  'video',    
	    'pages/shop/material/project/myNoteDetail':         'note',
		'pages/shop/material/project/sandbox':         		'panorama',
	    
	    'pages/client/project/traffic':			            'periphery',
	    'pages/client/project/building':			        'product',
	    'pages/client/project/unitTypeDetail':	            'house_type', 
	    'pages/client/project/buildingAlbumDetail':         'album',
	    'pages/client/project/buildingVideoDetail':         'video',    
	    'pages/client/project/myNoteDetail':                'note',
	    "pages/client/project/news":                        'news',
	    "pages/client/project/newsDetail":                  'news',
	    	    
	}
	
    const api = require("@/static/js/api.js")
    import uPopupNew from "../uPopupNew/u-popup.vue"
    import {
        mapState,
        mapMutations,
        mapActions
    } from 'vuex';
    let timeId = null
    export default {
        data() {
            return {
                isShow: false,
            };
        },
        computed: {
            ...mapState({
                hasLogin: state => state.userInfo.hasLogin,
            }),
        },
        components: {
            uPopupNew
        },
        props: {
            value: {
                type: Boolean
            },
            routePage:{
               type: String,
               default: ''
            }
        },
        watch: {
            value: {
                handler: function observer(val) {
                    var that = this;
                    that.isShow = val;
                },
                immediate: true
            },
            isShow:{
                handler: function observer(val) {
                    var _this = this;
                    this.$emit('input', val)
                },
                immediate: true
            }
        },
        computed: {
            ...mapState({
                hasLogin: state => state.userInfo.hasLogin,
                isAuthPhone: state => state.userInfo.isAuthPhone,
                isAuthUserInfo: state => state.userInfo.isAuthUserInfo,
                isAuthLocation: state => state.userInfo.isAuthLocation,
                isSeller: state => state.userInfo.isSeller,
                isReferrer: state => state.userInfo.isReferrer,
            }),
        },
        methods: {
            ...mapMutations(['setUserInfo', 'setLoginStatus', 'setUserId']),
            ...mapActions(['loginWechat', 'interceptorLoginInfoAuth','interceptorLoginPhoneAuth', 'updateUserInfo']),
            close(e) {
                let that = this
                that.isShow = false
                this.$emit('cancel');
            },
			onGetRedPacket(){
				let that = this
				that.isShow = false
				this.$emit('confirm');
				this.onGotoRedPacket();			
			},
			onGotoRedPacket(){
				let that = this
				if (that.hasLogin){
					let routes = getCurrentPages(); // 获取当前打开过的页面路由数组
					let curRoute = routes[routes.length - 1].route //获取当前页面路由
				    for(var key  in routeList){
				        if (key == curRoute){
							let type = routeList[key];
				            console.log('mixins:',routeList[key])                                               
							uni.navigateTo({
								url:"/pages/client/activity/activityRedpacket?type=" + type
							})
				        }
				    }
				}
			}

        }
    };
</script>


<style lang="scss">

	.resultContainer{
	    width: 580rpx;
	    height: 532rpx;
	    background-size: 100% 100%;
	    background-image: url(https://etalk.obs.cn-south-1.myhuaweicloud.com/popup_bg_red.png);
	    display: flex;
	    flex-direction: column;
	    align-items: center;
	    .wrapper{
	        width: 100%;
	        height: 330rpx;
	        display: flex;
	        flex-direction: column;
	        align-items: center;
	        justify-content: center;
	        margin-top: 40rpx;
	        .title{
	            font-size: 34rpx;
	            line-height: 54rpx;
	            letter-spacing: 3rpx;
	            color: #3a2b27;
	            font-weight: bold;
	        }
	        .redPacket{
	            font-size: 76rpx;
	            font-weight: normal;
	            font-stretch: normal;
	            line-height: 114rpx;
	            letter-spacing: 0rpx;
	            color: #d61608;
	            font-weight: bold;
	            .text{
	                font-size: 30rpx;
	                font-weight: normal;
	                font-stretch: normal;
	                letter-spacing: 3rpx;
	                color: #d61608;
	                font-weight: bold;
	            }
	        }
	        .titleFalse{
	            width: 250rpx;
	            font-size: 25rpx;
	            line-height: 36rpx;
	            letter-spacing: 2rpx;
	            color: #222222;
	            margin-top: 40rpx;
	        }
	
	    }
	    .btn{
	        width: 316rpx;
	        height: 70rpx;
	        background-image: linear-gradient(0deg, 
	            #fda204 0%, 
	            #feb705 10%, 
	            #ffcc05 47%, 
	            #ffde43 66%, 
	            #fef081 95%), 
	        linear-gradient(
	            #ffcb05, 
	            #ffcb05);
	        background-blend-mode: normal, 
	            normal;
	        border-style: solid;
	        border-width: 4rpx;
	        border-image-source: linear-gradient(0deg, 
	            #dc6700 0%, 
	            #f8d62c 100%);
	        border-image-slice: 1;
	        
	        font-size: 30rpx;
	        font-weight: normal;
	        font-stretch: normal;
	        line-height: 63rpx;
	        letter-spacing: 1rpx;
	        color: #3a2b27;
	        text-align: center;
	        margin-top: 20rpx;
	        border-radius: 35rpx;
	        font-weight: bold;
	    }
	    .tip{
	        font-size: 20rpx;
	        line-height: 36rpx;
	        letter-spacing: 2rpx;
	        color: #fefefe;
	        opacity: 0.8;
	        margin-top: 10rpx;
	    }
	
	}
</style>
